package com.ruoyi.hospital.discharge.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hospital.hospitalized.domain.THospitalized;
import com.ruoyi.hospital.hospitalized.service.ITHospitalizedService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 住院管理Controller
 *
 * @author Shawn
 * @date 2024-02-21
 */
@Controller
@RequestMapping("/hospital/discharge")
public class TDischargeController extends BaseController {
    private String prefix = "hospital/discharge";

    @Autowired
    private ITHospitalizedService tHospitalizedService;


    @GetMapping()
    public String hospitalized() {
        return prefix + "/discharge";
    }

    @GetMapping("/settlement")
    public String settlement(String id, ModelMap modelMap) {
        modelMap.addAttribute("id", id);
        return prefix + "/settlement";
    }

    /**
     * 查询住院管理列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(THospitalized tHospitalized) {
        startPage();
        //设置查询类型为出院
        tHospitalized.setAdmissionStatus("discharge");
        List<THospitalized> list = tHospitalizedService.selectTHospitalizedList(tHospitalized);
        return getDataTable(list);
    }


    @PostMapping("/settlement")
    @ResponseBody
    public AjaxResult settlement(THospitalized tHospitalized) {
        return toAjax(tHospitalizedService.settlement(tHospitalized));
    }

}
